#ifndef FGE_XMLUTIL_HPP
#define FGE_XMLUTIL_HPP

#include <stdexcept>
#include "tinyxml/tinyxml.h"

namespace fge
{
	template<typename T>
	T StringToNumber(const std::string& numberAsString)
	{
		T value;

		std::stringstream stream(numberAsString);
		stream >> value;
		if (stream.fail())
		{
			std::runtime_error e(numberAsString);
			throw e;
		}
		return value;
	}

	inline int GetChildCount(TiXmlNode *node, const std::string &childName)
	{
		TiXmlNode *child = NULL;
		int count = 0;
		while(child = node->IterateChildren(childName, child))
		{
			count++;
		}

		return count;
	}
}

#endif//FGE_XMLUTIL_HPP
